package cn.tedu.rabbitmqspringboot.m5;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;
import java.util.UUID;

//主题模式

@SpringBootApplication
public class Main {
    @Autowired
    private Producer p;

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Bean
    public Queue rndQueue1(){
        return new Queue(UUID.randomUUID().toString(),false,true,true);
    }
    @Bean
    public Queue ranQueue2(){
        return new Queue(UUID.randomUUID().toString(),false,true,true);
    }


    @Bean
    public TopicExchange logsExchange(){
        return new TopicExchange("topic_logs",false,false);
    }

    @PostConstruct
    public void test(){
        new Thread(() ->p.send()).start();
    }
}
